<template>
  <ul class="tree">
    <li v-for="item in data" :key="item.id" @click="$emit('click', item)">
      <a class="name" href="javascript:;">
        <DoubleRightOutlined class="icon" />
        <span>{{ item.name }}</span>
        <span v-if="item.count">({{ item.count }})</span>
      </a>
      <div class="child" v-if="item.child && item.child.length > 0">
        <Tree :data="item.child" v-on="$listeners"></Tree>
      </div>
    </li>
  </ul>
</template>

<script setup>
import { DoubleRightOutlined } from "@ant-design/icons-vue";
defineProps(["data"]);
defineEmits(["click"]);
</script>

<style lang="less">
.tree {
  .name {
    padding: 4px 8px;
    display: block;
    color: rgba(51, 51, 51, 0.88);
    font-size: 8px;
    display: flex;
    align-items: center;
    text-decoration: none;
    .icon {
      color: rgba(51, 51, 51, 0.88);
      font-size: 6px;
    }
    span {
      display: inline-block;
      margin-right: 6px;
    }
  }
  .child {
    padding-left: 15px;
  }
}
</style>
